#include"tcpserver.hpp"

#include"servercal.hpp"

Calculator ccl;

void OnMessage(Connection* ct)
{
    // std::cout << "get message: " << ct->_inbuffer << std::endl;
    std::cout << "get message: " << ct->_inbuffer << std::endl;
    std::string ret = ccl.server_cal(ct->_inbuffer);
    if(ret.empty()) return;

    ct->_outbuffer += ret;
    ct->_ts->Sender(ct);
}

int main()
{
    tcpserver ts(8080, OnMessage);
    ts.init();
    ts.loop();
    return 0;
}